package engine;


import com.tetris.project.Shr_Res;

import android.content.Context;
import android.graphics.Canvas;
import android.util.Log;
import framework.interfaces.Drawable;
import framework.interfaces.Updatable;
import framework.utils.GlobalManager;

public class GamePlayScene implements Drawable, Updatable{

	public Board mBoard;
	public Piece mCurrentPiece;
	public NextPiece mNextPiece;
	public BoardUI mBoardUI;
	public static Context context;

	public GamePlayScene(Context context)
	{
		GlobalManager.init(context);
		mBoard = new Board();
		mCurrentPiece = new Piece(0, 0, TetrisPieceManager.getRandomPiece(), mBoard);
		mNextPiece = new NextPiece(TetrisPieceManager.getRandomPiece(), mBoard);
		mBoardUI = new BoardUI(context);
		mBoard.definePieceUnitSize(mCurrentPiece.getUnitPieceWidth(), mCurrentPiece.getUnitPieceHeight());
		mBoardUI.setPieceUnitSize(mCurrentPiece.getUnitPieceWidth(), mCurrentPiece.getUnitPieceHeight());
		GamePlayScene.context = context; 
	}

	public Piece getPiece()
	{
		return mCurrentPiece;
	}

	@Override
	public void draw(Canvas canvas) {
		mBoardUI.setNextPiece(mNextPiece.getNextPiecePic());
		mBoardUI.draw(canvas); // Here it's drawn all stuff not related on game side.
		mBoard.draw(canvas); // Here is prepared the canvas for the game.
		mCurrentPiece.draw(canvas); // here is drawn the canvas.
		if (Shr_Res.blockWasForm){
			mBoardUI.showToast(canvas);
		}
	}

	@Override
	public void update(double arg) {
	}
}

